{
  //布尔类型

  //声明了一个布尔类型的变量
  let b: boolean;
  b = true;
  b = false;
  // b = 200; //  Type 'number' is not assignable to type 'boolean'

  let b2: boolean = true;
  b2 = false;
  // b2 = 'abc'; // Type 'string' is not assignable to type 'boolean'

  //数字类型
  let n: number;
  n = 100; //十进制
  n = 0b1010; // 二进制
  n = 0o777; // 八进制
  n = 0xff; // 十六进制
  // n = 'abc';
  // n = '123'; // Type 'string' is not assignable to type 'number'.
  let n2: number = 521;
  // console.log(n2);

  //字符串类型
  let s: string;
  s = "i love you";
  s = "i miss you";
  s = `i want you`;

  let s2: string = "如果你是一匹千里马，那么请做自己的伯乐";
  console.log(s2);

  //字面量值类型 像常量
  let x: "love" = "love";
  let x2: true;
  x2 = true;
  let x3: null;
  x3 = null;

  //any 任意   不会对 any 类型的变量进行类型检测
  let a: any;
  a = 100;
  a = "abc";
  a = true;

  //void 类型
  let v: void;
  v = undefined;
  function fn(): void {}

  //object 类型
  let o: object;
  o = { a: 100, b: 200 };
  o = ["1", "2", "3"];
  o = function () {};

  //array 数组类型  [1,'a',true]
  let arr: string[] = ["zhangsan", "lisi", "wangwu"];
  arr.push("zhaosi");

  let arr2: Array<number> = [1, 2, 3, 4];
  arr2.unshift(0);

  //元组
  let t: [string, number] = ["古天乐", 51];
  let stus: [string, number][] = [
    ["王淼", 18],
    ["徐东", 18],
  ];
  console.log(stus);

  //枚举类型  defineProperty  create
  enum Gender {
    female = "女",
    male = "男",
    secret = "保密",
  }

  let obj = {
    name: "张三",
    age: 18,
    gender: Gender.male,
  };

  console.log(obj);

  //联合类型
  let key: number | string | boolean;
  key = 100;
  key = "axy";
  key = true;

  let key2: 0 | 1;
  // key2 = 3;

  //类型断言
  let div = document.querySelector("#root") as HTMLElement;
  //方式一
  // (div as HTMLElement).style.background = '#aef';
  div.style.background = "#789";

  //方拾二
  // (<HTMLElement>div).style.background = "#999";

  //类型推断
  let xyz = 100;
  // xyz = 'abc';

  let abc;
  abc = 100;
  abc = "abc";
  abc = true;
  abc = ["1", "2"];
}
